home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / demos / dcd_demo.arc / SAMPLE.S < prev   
Text File  |  1990-03-23  |  6KB  |  196 lines

  1.     opt o+,a+,ow-
  2.  
  3.     TEXT
  4. ;
  5. ; SAMPLE.PRG - sample RAM resident program for DC DESKTOP
  6. ;
  7. ; This code is given as an example, and is therefore PUBLIC DOMAIN.
  8. ; Code used in DC DESKTOP are copyright (c) 1990 Double Click Software
  9. ;
  10. ; This is sample to code to demonstrate how to make a RAM resident program
  11. ; which can be called from DC DESKTOP.
  12. ;
  13. ; This allows programs to be installed from the AUTO folder, and stay RAM
  14. ; resident until the program is called.
  15. ;
  16. ; NOTE: GEM programs which have a resource included should fix up the
  17. ;        resource _only once_ when the program is first called from DC DESKTOP
  18. ;
  19. ;        GEM programs which load a resource should note that the default
  20. ;        path is used, and should have a hard-coded resource path, or
  21. ;        should have a way for the user to locate the resource.
  22. ;
  23. ;        Self-modifying code should be careful that when the program is
  24. ;        called again, it executes correctly.
  25. ;
  26. ;        1024 bytes of supervisor and user stack are given to the program
  27. ;        when jsr'ed to from DC DESKTOP.  If more is needed, you should
  28. ;        give yourself more.
  29. ;
  30.  
  31. * Macro library to call AES & VDI
  32. * Copyright (c) HiSoft 1988
  33.  
  34. * 31.5.88   fixed appl_read,appl_write,graf_slidebox
  35. * 2.6.88    fixed evnt_multi
  36.  
  37. ***********AES Macros******************
  38.  
  39. * macro to call a given AES routine
  40. aes macro   aes_number
  41.     XREF    CALL_AES,int_in,addr_in,int_out,addr_out,current_handle
  42.     moveq   #\1,d0
  43.     bsr CALL_AES
  44.     endm
  45. *   may need to change BSR CALL_AES to JSR for large programs
  46.  
  47.  
  48. form_alert  macro   button,string
  49.     move.w  \1,int_in
  50.     move.l  \2,addr_in
  51.     aes 52
  52.     endm
  53.  
  54. *********** END OF AES *************
  55.  
  56. sop:
  57.     move.l  #mystack,a7            ; we need a local stack
  58.  
  59.     move.l  #test,-(a7)            ; see if DC DESKTOP is present - execute
  60.     move.w  #38,-(a7)            ; test function in Supervisor mode
  61.     trap    #$e                    ; Supexec - XBIOS
  62.     addq.l  #6,a7                ; fix stack
  63.  
  64.     tst.l   d0                    ; DC DESKTOP present?
  65.     bne.s   .1                    ; nope
  66.  
  67.     lea     do_it,a0            ; pointer to our routine to be called when
  68.     move.l  #$72000d,d0         ; numeric enter is pressed
  69.     moveq    #3,d1                ; with left-shift and right-shift
  70.     move.w  #$dc03,-(a7)        ; DC DESKTOP functin to register a resident
  71.                                 ; program and keystrokes to call it
  72.     trap    #9                    ; DC DESKTOP trap handler
  73.     addq.l  #6,a7                ; fix stack
  74.  
  75.     tst.l   d0                    ; did it work? (only 26 allowed!)
  76.     beq.s   .0                    ; yes
  77. .1:
  78.     pea     no_show_name        ; nope, not installed text
  79.     move.w  #9,-(a7)            ; Cconws
  80.     trap    #1                    ; GEMDOS
  81.     addq.l  #6,a7                ; fix stack
  82.  
  83.     clr.w   -(a7)                ; Pterm0 - terminate program
  84.     trap    #1                    ; do it - GEMDOS
  85.  
  86. .0:
  87.     pea     show_name            ; installed text
  88.     move.w  #9,-(a7)            ; Cconws
  89.     trap    #1                    ; GEMDOS
  90.     addq.l  #6,a7                ; fix stack
  91.  
  92.     clr.w   -(a7)                ; always zero
  93.     move.l  #eop,d0                ; end-of-program
  94.     sub.l   #sop,d0                ; minus start-of-program = total size
  95.     add.l    #$100,d0            ; plus basepage size
  96.     move.l  d0,-(a7)            ; memory size to keep
  97.     move.w  #$31,-(a7)            ; Ptermres - terminate and stay resident
  98.     trap    #1                    ; GEMDOS
  99.  
  100. test:
  101.         moveq   #-1,d0            ; set to fail
  102.         move.l  $a4.w,a0        ; trap 9 vector number
  103.         cmp.w   #$dc,-(a0)        ; is the word before what it points to $dc?
  104.         bne.s   .1                ; nope - DC DESKTOP not present
  105.         moveq   #0,d0            ; yes - DC DESKTOP present
  106. .1:
  107.         rts                        ; return
  108.  
  109. ;
  110. ; DC DESKTOP resident program header:
  111. ; This header MUST be present and is used to validate the program
  112. ;
  113. ; program_name:
  114. ;    dc.b    14        ; Name of program to run (VALID filename: GEM or TOS)
  115.                     ; must be 14 chars long (can be .PRG, .TTP, .TOS, .APP)
  116. ; magic_word:
  117. ;    dc.w    $dcdc    ; magic word to verify resident program is valid
  118. ;
  119.  
  120. program_name:                            ; our protocol needs a header
  121.     dc.b    'SAMPLE.PRG',0,0,0,0        ; before the address to jump to
  122. magic_word:
  123.     dc.w    $dcdc
  124.  
  125. do_it:                                    ; jsr to here when lshift+rshift+
  126.     form_alert    #1,#sample_alert        ; numeric enter is pressed
  127.     rts                                    ; return to DC DESKTOP
  128.  
  129.  
  130. * AES Library Copyright (C) HiSoft 1988
  131. * this MUST be assembled to either executable or GST linkable, NOT DRI code
  132.  
  133. * sets section order to TEXT,DATA,BSS
  134.  
  135. * the actual calling of the AES
  136.  
  137.     MODULE  LowLevelAES
  138.  
  139.     XDEF    CALL_AES,control,global,int_in,int_out
  140.     XDEF    addr_in,addr_out,aes_params
  141.  
  142.     TEXT
  143. * call an AES routine
  144. * in:   d0.w=AES function number
  145. * out   d0.w=int_out value
  146. * uses  d0-d2/a0-a2
  147. * (assumes control4 needs to be zero)
  148. CALL_AES    lea control,a1
  149.     move.w  d0,(a1)+            store the op code
  150.     lea     gemaes52,a0
  151.     move.w  (a0)+,(a1)+ control1
  152.     move.w  (a0)+,(a1)+ and control2
  153.     move.w  (a0)+,(a1)+ and control3
  154.     clr.w   (a1)            assumes control4=0 (all except RSRC_GADDR)
  155.     move.l  #aes_params,d1
  156.     move.w  #200,d0         function number
  157.     trap    #2
  158.     move.w  int_out,d0      usually a returned value
  159.     rts
  160.  
  161.     DATA
  162.  
  163. * this is a table of pointers to all the AES arrays
  164. aes_params  dc.l    control,global,int_in,int_out,addr_in,addr_out
  165.  
  166. * this is the list of Control parameters for the AES calls
  167. * contains control(1..3), comment is the function number
  168. * (an asterisk indicates it is not defined)
  169.  
  170. gemaes52    dc.w    1,1,1   52
  171.  
  172.     EVEN
  173.  
  174. *********** END OF AES *****************
  175.  
  176.     DATA
  177.  
  178. show_name:
  179.     dc.b    'Sample program installed!',0
  180. no_show_name:
  181.     dc.b    'Sample program not installed!',0
  182. sample_alert:
  183.     dc.b    '[3][Sample][OK]',0
  184.  
  185.     BSS
  186.  
  187. control     ds.w        4
  188. global      ds.w        14
  189. int_in      ds.w        16
  190. int_out     ds.w        7
  191. addr_in     ds.l        2
  192. addr_out    ds.l        1
  193.  
  194.     ds.l    $50
  195. mystack:
  196. eop: